package net.neptech.controller;

import net.neptech.service.PermissionService;
import net.neptech.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

/**
 * 权限控制器 - 提供权限和角色查询接口
 */
@RestController
@RequestMapping("/api/permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    /**
     * 获取当前用户的角色列表
     */
    @GetMapping("/roles")
    public ResponseResult<Set<String>> getUserRoles() {
        Set<String> roles = permissionService.getRolePermission();
        return ResponseResult.success(roles);
    }

    /**
     * 获取当前用户的权限列表
     */
    @GetMapping("/permissions")
    public ResponseResult<Set<String>> getUserPermissions() {
        Set<String> permissions = permissionService.getMenuPermission();
        return ResponseResult.success(permissions);
    }
}